package buxfer;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

import java.util.concurrent.TimeUnit;

/**
 * Created with IntelliJ IDEA.
 * User: stem
 * Date: 14.11.13
 * Time: 23:06
 * To change this template use File | Settings | File Templates.
 */
public class Home {
    @FindBy(id="login_username")
    private WebElement name;
    @FindBy(id="login_password")
    private WebElement pass;
    @FindBy(xpath="//*[@id='login_form']//div[@class=' button']")
    private WebElement btn;
    @FindBy(xpath="//a[@href='/signup']")
    private WebElement btnSignup;
    private WebDriver driver;
    public Home(WebDriver driver){
        this.driver=driver;
        PageFactory.initElements(driver,this);
    }
    public assertPage login(String logname,String logpass){
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        name.click();
        name.clear();
        name.sendKeys(logname);
        pass.click();
        pass.clear();
        pass.sendKeys(logpass);
        btn.click();
        return new assertPage(driver);

    }
    public menuPage login(String logname,String logpass,String s){
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        name.click();
        name.clear();
        name.sendKeys(logname);
        pass.click();
        pass.clear();
        pass.sendKeys(logpass);
        btn.click();
        return new menuPage(driver);

    }

    public Reg reg(){
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        name.click();
        name.clear();
        pass.click();
        pass.clear();
        btn.click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        btnSignup.click();
        return new Reg(driver);
    }

}
